gboolean has_default_palette;
GSettings *settings;
+
+ int max_custom;
};
struct _GtkColorChooserWidgetClass
gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
gtk_grid_set_column_spacing (GTK_GRID (grid), 4);
gtk_box_append (GTK_BOX (cc->palette), grid);
-
left = 0;
right = colors_per_line - 1;
gtk_grid_attach (GTK_GRID (grid), p, line, pos, 1, 1);
}
}
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ cc->max_custom = MAX (cc->max_custom, colors_per_line);
+ else
+ cc->max_custom = MAX (cc->max_custom, n_colors / colors_per_line);
}
static void
remove_palette (cc);
cc->has_default_palette = FALSE;
+ cc->max_custom = 0;
}
static void
const GdkRGBA *color)
{
GtkWidget *widget;
- GList *children;
GtkWidget *p;
+ int n;
- children = NULL;
+ n = 0;
for (widget = gtk_widget_get_first_child (cc->custom);
widget != NULL;
widget = gtk_widget_get_next_sibling (widget))
- children = g_list_prepend (children, widget);
+ n++;
- if (g_list_length (children) >= 8)
+ while (n >= cc->max_custom)
{
GtkWidget *last = gtk_widget_get_last_child (cc->custom);
cc->current = NULL;
gtk_box_remove (GTK_BOX (cc->custom), last);
+ n--;
}
- g_list_free (children);
p = gtk_color_swatch_new ();
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (p), color);